﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DTO;

namespace DAO
{
    public class DatMonDAO
    {
        public static DataTable GetMaDM(int ban)
        {
            string sql = string.Format("select MADM FROM DATMON WHERE MABAN={0} and MATINHTRANG=1",ban);
            return DataProvider.ExcuteQuery(sql);
        }
        public static DataTable Addnew(DatMonDTO dm)
        {
            string sql = string.Format("insert into DATMON(MABAN,MATINHTRANG) VALUES ('{0}','{1}') SELECT SCOPE_IDENTITY() as ID", dm.Maban, dm.Tinhtrang);
            return DataProvider.ExcuteQuery(sql);
        }
        public static DataTable GetTopID()
        {
            string sql = string.Format("select top 1 * from DATMON  order by MADM desc");
            return DataProvider.ExcuteQuery(sql);
        }
        public static int Thanhtoan(int madm)
        {
            string sql = string.Format("update DATMON set MATINHTRANG=2 where MADM={0}", madm);
            return DataProvider.ExcuteNonQuery(sql);
        }
        

    }
}
